package edu.tsinghua.ddb.data;

import java.sql.SQLException;

import com.sun.rowset.CachedRowSetImpl;

import edu.tsinghua.ddb.util.Conf;

public class DataAccess {


	private CachedRowSetImpl crs;

	public DataAccess() {
		try {
			Class.forName("org.gjt.mm.mysql.Driver").newInstance();
			crs = new CachedRowSetImpl();
			crs.setUsername("root");
			crs.setPassword("kuaisan");
			String url = Conf.get("conn");
			crs.setUrl(url);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
	}

	public CachedRowSetImpl localQuery(String sqlString) {
		try {
			crs.setCommand(sqlString);
			crs.execute();
			return crs;
		} catch (SQLException e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return null;
	}
}
